package com.donfu.web.controller.house;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.donfu.common.annotation.Log;
import com.donfu.common.core.controller.BaseController;
import com.donfu.common.core.domain.AjaxResult;
import com.donfu.common.enums.BusinessType;
import com.donfu.system.domain.house.HouseCommentLike;
import com.donfu.system.service.house.IHouseCommentLikeService;
import com.donfu.common.utils.poi.ExcelUtil;
import com.donfu.common.core.page.TableDataInfo;

/**
 * 评论点赞Controller
 * 
 * @author donfu
 * @date 2021-12-01
 */
@RestController
@RequestMapping("/house/like")
public class HouseCommentLikeController extends BaseController
{
    @Autowired
    private IHouseCommentLikeService houseCommentLikeService;

    /**
     * 查询评论点赞列表
     */
    @PreAuthorize("@ss.hasPermi('house:like:list')")
    @GetMapping("/list")
    public TableDataInfo list(HouseCommentLike houseCommentLike)
    {
        startPage();
        List<HouseCommentLike> list = houseCommentLikeService.selectHouseCommentLikeList(houseCommentLike);
        return getDataTable(list);
    }

    /**
     * 导出评论点赞列表
     */
    @PreAuthorize("@ss.hasPermi('house:like:export')")
    @Log(title = "评论点赞", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(HouseCommentLike houseCommentLike)
    {
        List<HouseCommentLike> list = houseCommentLikeService.selectHouseCommentLikeList(houseCommentLike);
        ExcelUtil<HouseCommentLike> util = new ExcelUtil<HouseCommentLike>(HouseCommentLike.class);
        return util.exportExcel(list, "评论点赞数据");
    }

    /**
     * 获取评论点赞详细信息
     */
    @PreAuthorize("@ss.hasPermi('house:like:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return AjaxResult.success(houseCommentLikeService.selectHouseCommentLikeById(id));
    }

    /**
     * 新增评论点赞
     */
    @PreAuthorize("@ss.hasPermi('house:like:add')")
    @Log(title = "评论点赞", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HouseCommentLike houseCommentLike)
    {
        return toAjax(houseCommentLikeService.insertHouseCommentLike(houseCommentLike));
    }

    /**
     * 修改评论点赞
     */
    @PreAuthorize("@ss.hasPermi('house:like:edit')")
    @Log(title = "评论点赞", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HouseCommentLike houseCommentLike)
    {
        return toAjax(houseCommentLikeService.updateHouseCommentLike(houseCommentLike));
    }

    /**
     * 删除评论点赞
     */
    @PreAuthorize("@ss.hasPermi('house:like:remove')")
    @Log(title = "评论点赞", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(houseCommentLikeService.deleteHouseCommentLikeByIds(ids));
    }
}
